/**
 * *******************************************
 * user: zmq
 * describe:    初始化服务器service
 * created:
 * date: 2021/8/31
 * *******************************************
 */

import {Application} from "pinus";
import {SvrType} from "../consts/consts";
import areaService from "../service/areaService";
import gateService from "../service/gateService";
import connectorService from "../service/connectorService";

/**
 * 初始化接口
 * @param app
 */
export function svrInit(app: Application) {
    switch (app.serverType) {
        case SvrType.gate: {
            gateServiceInit(app);
            break;
        }
        case SvrType.connector:{
            connectorServiceInit(app);
            break;
        }
        case SvrType.area: {
            areaServiceInit(app);
            break;
        }
        default:
            break;
    }
}

/**
 * gateService初始化
 * @param app
 */
function gateServiceInit(app: Application) {
    gateService.init();
}

/**
 * connectorService初始化
 * @param app
 */
function connectorServiceInit(app: Application) {
    connectorService.init();
}

/**
 * areaService初始化
 * @param app
 */
function areaServiceInit(app: Application) {
    areaService.init(app.getServerId());
}